	function checkCurrentForm(){
		var objs = document.getElementsByName("id");
		var sign = 0;
		for(var i = 0; i < objs.length; i++){
			if(objs[i].value != 0 && objs[i].checked)sign = sign + 1;
		}
		if(sign <= 0){
			alert("请选择待操作的项！");
			return false;
		}else if(sign > 1){
			alert("只能选择一个待操作项！");
			return false;
		}
		return true;
	}

  function addContractCase(obj,isSub){
		var url = "./contract.do?action=preAddContractCase&isSub="+isSub;
		var dlgParam = "dialogHeight:400px;dialogWidth:850px;dialogTop:300px;dialogLeft:400px;status:no;help:no;scrollbars:yes;";
		
		var trObj=$(obj).parent().parent();
  		var tdObjs = $(trObj).children();
  		var v_td_processId;
  		var v_td_processName;
  		var v_td_applicationCode;
  		var v_td_applicationDate;
  		var v_td_description;
  		$(tdObjs).each(function(index,tdObj){
  			if($(tdObj).children("input[id='processGroupId']").val()!=null){
  				url+= "&processGroupId="+$(tdObj).children("input[id='processGroupId']").val();
  			}
  			if($(tdObj).children("input[id='processId']").val()!=null){
  				url+= "&processId="+$(tdObj).children("input[id='processId']").val();
  				v_td_processId=$(tdObj)
  			}
  			if($(tdObj).children("input[id='processName']").val()!=null){
  				url+= "&processName="+$(tdObj).children("input[id='processName']").val();
  				v_td_processName=$(tdObj);
  			}
  			if($(tdObj).children("input[id='applicationCode']").val()!=null){
  				url+= "&applicationCode="+$(tdObj).children("input[id='applicationCode']").val();
  				v_td_applicationCode=$(tdObj);
  			}
  			if($(tdObj).children("input[id='applicationDate']").val()!=null){
  				url+= "&applicationDate="+$(tdObj).children("input[id='applicationDate']").val();
  				v_td_applicationDate=$(tdObj);
  			}
  				
  			if($(tdObj).children("input[id='description']").val()!=null){
  				url+= "&description="+$(tdObj).children("input[id='description']").val();
  				v_td_description=$(tdObj);
  			}
  				
  			if($(tdObj).children("input[id='mark']").val()!=null){
  				url+= "&mark="+$(tdObj).children("input[id='mark']").val();
  			}
  			if($(tdObj).children("input[id='caseId']").val()!=null){
  				url+= "&caseId="+$(tdObj).children("input[id='caseId']").val();
  			}
  				
  		});
  		 
		var rt = window.showModalDialog(url,"",dlgParam); 
	
		if(rt != undefined){
			var returnStr = rt.split(",");
			$(v_td_processId).children("input[id='processId']").val(returnStr[0]);
			$(v_td_processName).children("input[id='processName']").val(returnStr[1]);
			$(v_td_applicationCode).children("input[id='applicationCode']").val(returnStr[2]);
			$(v_td_applicationDate).children("input[id='applicationDate']").val(returnStr[3]);
			$(v_td_description).children("input[id='description']").val(returnStr[4]);
		}
		return true;
	}	
		
	function prepareInsertHtml(tableId,num , caseCode, applicationCode, desc, typeid, firstProcess,vprocessId,vprocessGroupId,isAdd){
		var insertHtml = new Array();//用于插入新记录的HTML
		var mark=caseCode+'_'+typeid;
		var submark='sub_'+caseCode+'_'+typeid;
		insertHtml[0] =  "<a href='#' onclick=\"delRow('"+mark+"')\"><font color='blue'>删除</font></a>";
		insertHtml[1] =  "<a href='#' onclick=\"addSubCase("+tableId+",'"+submark+"',"+num+")\"><font color='blue'>(+)</font></a>";
		insertHtml[1] += "<input id='contractCaseName' name='contractCaseName' class='input_percent' style='width:300px' type='text' value='"+caseCode+"' readonly/>";
		insertHtml[1] += "<input id='caseCode' name='caseCode' type='hidden' value='"+caseCode+"'/>";
		insertHtml[1] += "<input id='applicationCode' name='applicationCode' type='hidden' value='"+applicationCode+"' />";
		insertHtml[1] += "<input id='description' name='description' type='hidden' value='"+desc+"'/>";
	    insertHtml[1] += "<input id='typeId' name='typeId' type='hidden' value='"+typeid+"'/>";
		insertHtml[1] += "<input id='suffixCaseName' name='suffixCaseName' class='input_percent' style='width:90px' type='text'/>";
		insertHtml[1] += "<input id='mark' name='mark' type='hidden' value='"+mark+"'/>";
		if(isAdd==0)
		    insertHtml[2] ="<input class='btn_select' type='button' onclick='addContractCase(this)' hidefocus='true'/>";
		else
			insertHtml[2] ="&nbsp;";
		
		insertHtml[3] =  "<input id='processName' name='processName' class='input_percent' type='text' value='"+firstProcess+"'/>";
		insertHtml[3] += "<input id='processId' name='processId' type='hidden' value='"+vprocessId+"'/>";
		insertHtml[3] += "<input id='processGroupId' name='processGroupId' type='hidden' value='"+vprocessGroupId+"'/>";
		
		insertHtml[4] =  "<input id='costValue' name='costValue' class='input_percent' type='text'/>";
		insertHtml[5] =  "<input id='officialCost' name='officialCost' class='input_percent' type='text'/>";
		insertHtml[6] =  "<input id='operationCost' name='operationCost' class='input_percent' type='text'/>";
		insertHtml[7] =  "<input id='proxyCost' name='proxyCost' class='input_percent' type='text'/>";
		insertHtml[7] += "<input id='applicationDate' name='applicationDate' type='hidden' value=''/>";
		insertHtml[7] += "<input id='caseId' name='caseId' type='hidden' value=''/>";
		insertHtml[7] += "<input id='attachId' name='attachId' type='hidden' value=''/>";
		return insertHtml;
	}
	
	function prepareInsertSubHtml(num,subMark){
		var insertHtml = new Array();//用于插入新记录的HTML
		insertHtml = [];
		insertHtml[0] ="<a href='#' onclick=\"delSubRow(this)\"><font color='blue'>删除</font></a>";
		insertHtml[1] = "<input id='suffixCaseName' name='suffixCaseName' class='input_percent' style='width:90px' type='text'/>";
		insertHtml[1] += "<input id='contractCaseName' name='contractCaseName' type='hidden' value=''/>";
		insertHtml[1] += "<input id='caseCode' name='caseCode' type='hidden' value=''/>";
		insertHtml[1] += "<input id='applicationCode' name='applicationCode' type='hidden' value=''/>";
		insertHtml[1] += "<input id='description' name='description' type='hidden' value=''/>";
		insertHtml[1] += "<input id='typeId' name='typeId' type='hidden' value=''/>";
		insertHtml[1] += "<input id='processId' name='processId' type='hidden' value='0'/>";
		insertHtml[1] += "<input id='processGroupId' name='processGroupId' type='hidden' value='0'/>";
		insertHtml[2] = "&nbsp;";
		insertHtml[3] = "<input id='processName' name='processName' type='hidden' value=''/>";
		insertHtml[4] = "<input id='costValue' name='costValue' class='input_percent' type='text'/>";
		insertHtml[5] = "<input id='officialCost' name='officialCost' class='input_percent' type='text'/>";
		insertHtml[6] = "<input id='operationCost' name='operationCost' class='input_percent' type='text'/>";
		insertHtml[7] = "<input id='proxyCost' name='proxyCost' class='input_percent' type='text'/>";
		insertHtml[7] += "<input id='mark' name='mark' type='hidden' value='"+subMark+"'/>"; 
		insertHtml[7] += "<input id='applicationDate' name='applicationDate' type='hidden' value=''/>";
		insertHtml[7] += "<input id='caseId' name='caseId' type='hidden' value=''/>";
		insertHtml[7] += "<input id='attachId' name='attachId' type='hidden' value=''/>";
		return insertHtml;
	}
	
	function delRow(mark){
		//$("tr[id='"+num+"']").remove();
		$("tr[id *="+mark+"]").remove();//删除当前行
		$("tr[id *='sub_"+mark+"']").remove();//删除当前行
	}
	function delSubRow(obj){
		
		$(obj.parentElement.parentElement).remove();//删除当前行
	}
	//tableId,num,
	function addSubCase(tableId,subMark,num){
		var subInsertHtml=prepareInsertSubHtml(num,subMark);
		addRow(tableId.id,subInsertHtml,subMark);
	}